package com.upu173.music.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import android.view.MenuItem;

import com.andbase.library.app.base.AbBaseActivity;
import com.andbase.library.utils.AbLogUtil;
import com.upu173.music.R;
import com.upu173.music.fragment.MusicBarFragment;
import com.upu173.music.model.PlayList;
import com.upu173.music.model.Song;

import java.util.List;

public class MusicBaseActivity extends AbBaseActivity {

    public MusicBarFragment musicBarFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AbLogUtil.i("pageClassName:",pageClassName);
        showMusicBar();
    }

    public void showMusicBar(){
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        if (musicBarFragment == null) {
            musicBarFragment = new  MusicBarFragment();
            ft.add(R.id.fragment_music_bar, musicBarFragment).commit();
        }else {
            ft.show(musicBarFragment);
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == android.R.id.home) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void initPlayList(List<PlayList> playLists){
        musicBarFragment.initPlayList(playLists);

    }

}
